package cc.laop.mq.kafka.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.listener.MessageListener;

/**
 * Created by Pengpeng on 2017/5/26.
 */
public class ConsumerListener1 implements MessageListener<String, String> {

    private static final Logger logger = LoggerFactory.getLogger(ConsumerListener.class);


    @Override
    public void onMessage(ConsumerRecord<String, String> consumerRecord) {

        String topic = consumerRecord.topic();
        String key = consumerRecord.key();
        String value = consumerRecord.value();
        long offset = consumerRecord.offset();
        int partition = consumerRecord.partition();
        logger.info("Recive message top-1. topic: {}, key: {}, value: {}, offset: {}, partition: {}",
                new Object[]{topic, key, value, offset, partition});
    }

}
